
#include "GSSystem_globals.h"

#ifndef GS_LIB
	#include "MemoryDefs_impl.h"
#endif

#include "CSystem.h"

void * g_hInst = 0;

static SSystemGlobalEnvironment global_env;

SSystemGlobalEnvironment * gEnv = &global_env;

void pureCallError()
{
	std::cout << std::endl << "!!!!!!!! PURE CALL, ERROR!!! !!!!!!" << std::endl;
}

ISystem * getSystemInterface()
{
	// for avoiding pure virtual function call (if out of sync with dll)
	_set_purecall_handler(pureCallError);

	static char pSysBuffer[sizeof(CSystem)];

	gEnv->p_system = new((void*)pSysBuffer) CSystem();

	return gEnv->p_system;
}

BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason, LPVOID reserved)
{
	if (reason == DLL_PROCESS_ATTACH)
	{
		g_hInst = hInst;		
	}

	return TRUE;
}